import request from '../utils/request'
import type { Registration } from '../types/registration'

export const registrationApi = {
  // 报名活动
  register(data: { userId: number; eventId: number; formData: string }) {
    return request.post<Registration>(
      `/registrations?userId=${data.userId}&eventId=${data.eventId}`,
      data.formData,
      { headers: { 'Content-Type': 'application/json' } }
    )
  },

  // 获取报名详情
  getRegistration(id: number) {
    return request.get<Registration>(`/registrations/${id}`)
  },

  // 获取用户的报名记录
  getUserRegistrations(userId: number) {
    return request.get<Registration[]>(`/registrations/user/${userId}`)
  },

  // 获取活动的报名记录
  getEventRegistrations(eventId: number) {
    return request.get<Registration[]>(`/registrations/event/${eventId}`)
  }
} 